Application that sends a message to a Telegram chat.
npm run start:development -w packages/send-telegram-message
This command uploads the source code to Cloud Build, which builds the container image and deploys the application to Cloud Functions (2nd generation):
npm run deploy -w packages/send-telegram-message
Run integration tests with SuperTest and Jest:
npm run test -w packages/send-telegram-message
Start the function in one terminal:
npm run start:development -w packages/send-telegram-message
And call it with curl, Postman, etc:
curl -X POST \
-L "$SEND_TELEGRAM_MESSAGE_URL" \
-H "Content-Type: application/json" \
--data-raw '{
"text": "Hello world in <b>bold</b> and <i>italic</i>"
}'
If you want to test the function with curl (or Postman, etc) don't forget to include the identity token in the Authorization
header, otherwise Google will return a HTTP 403.
Here is how you can make an authenticated request using the user account you are currently logged in:
curl -X POST \
-L "$SEND_TELEGRAM_MESSAGE_URL" \
-H "Authorization: Bearer $(gcloud auth print-identity-token)" \
-H "Content-Type: application/json" \
--data-raw "{
\"text\": \"This is a message sent by <b>curl</b>\"
}"