Skip to content

Commit

Permalink
fix(create-twilio-function): fix hello-world template (#531)
Browse files Browse the repository at this point in the history
* fix(create-twilio-function): fix hello-world template

* fix(create-twilio-function): add changeset
  • Loading branch information
AndreLars authored Jan 24, 2025
1 parent 2bc2beb commit b18bbec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
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);
};
};

0 comments on commit b18bbec

Please sign in to comment.