Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sour-impalas-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-twilio-function': minor
---

fix hello-world template
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ import {
Context,
ServerlessCallback,
ServerlessFunctionSignature,
ServerlessEventObject,
} from '@twilio-labs/serverless-runtime-types/types';

type MyEvent = {
Body?: string
}
Body?: string;
};

// If you want to use environment variables, you will need to type them like
// this and add them to the Context in the function signature as
// Context<MyContext> as you see below.
type MyContext = {
GREETING?: string
}
GREETING?: string;
};

export const handler: ServerlessFunctionSignature = function(
export const handler: ServerlessFunctionSignature = function (
context: Context<MyContext>,
event: MyEvent,
event: ServerlessEventObject<MyEvent>,
callback: ServerlessCallback
) {
const twiml = new Twilio.twiml.VoiceResponse();
twiml.say(`${context.GREETING ? context.GREETING : 'Hello'} ${event.Body ? event.Body : 'World'}!`);
twiml.say(
`${context.GREETING ? context.GREETING : 'Hello'} ${
event.Body ? event.Body : 'World'
}!`
);
callback(null, twiml);
};
};
Loading