Skip to content

Instantly share code, notes, and snippets.

@megaya
Created January 21, 2022 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save megaya/99e0372d5e902d1bb747eb3459c5033d to your computer and use it in GitHub Desktop.
Save megaya/99e0372d5e902d1bb747eb3459c5033d to your computer and use it in GitHub Desktop.
const Alexa = require('ask-sdk-core');
const {
WebClient
} = require('@slack/web-api');
const TOKEN = 'Slack botのトークンをここに入れる';
const LaunchRequestHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
},
handle(handlerInput) {
const speakOutput = '何をメモしますか?';
return handlerInput.responseBuilder.speak(speakOutput).reprompt(speakOutput).getResponse();
}
};
const SlackIntentHandler = {
canHandle(handlerInput) {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
},
handle(handlerInput) {
const channel = '#声メモ';
const text = handlerInput.requestEnvelope.request.intent.slots.memo.value;
const client = new WebClient(TOKEN);
client.chat.postMessage({
channel,
text
});
return handlerInput.responseBuilder.speak('投稿しました').getResponse();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment