はじめに
@client.reply_message(event['replyToken'], {
"type": "template",
"altText": "this is a image carousel template",
"template": {
"type": "image_carousel",
"columns": [
{
"imageUrl": "<画像のURL>",
"action": {
"type": "message",
"label": "選択1",
"text": "選択1"
}
},
{
"imageUrl": "<画像のURL>",
"action": {
"type": "message",
"label": "選択2",
"text": "選択2"
}
},
{
"imageUrl": "<画像のURL>",
"action": {
"type": "uri",
"label": "Yahoo",
"uri": "http://www.yahoo.co.jp"
}
}
]
}
})
確認メッセージ
@client.reply_message(event['replyToken'], {
"type": "template",
"altText": "確認",
"template": {
"type": "confirm",
"text": "あなたの性別は?",
"actions": [
{
"type": "message",
"label": "男性",
"text": "男性"
},
{
"type": "message",
"label": "女性",
"text": "女性"
}
]
}
})
@client.reply_message(event['replyToken'], {
"type": "flex",
"altText": "this is a flex message",
"contents": {
"type": "bubble",
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"text": "ああああああああああああああああああああああああ"
},
{
"type": "text",
"text": "いいいいいいいいいいいいいいいいいいいいいいい"
}
]
}
}
})
ユーザー情報取得
events = @client.parse_events_from(body)
events.each do |event|
user_id = event["source"]["userId"]
response = @client.get_profile(user_id)
case response
when Net::HTTPSuccess then
contact = JSON.parse(response.body)
logger.debug("これだよね")
logger.debug(contact)
else
logger.debug("#{response.code} #{response.body}")
end
end
- 取得内容は下記のデータです。電話番号までは取得できないのが残念
{"userId"=>"<取得したUserId>", "displayName"=>"<ユーザーの名前>", "language"=>"ja"}