Skip to content

fix(create-twilio-function): fix hello-world template #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2025
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